#!/usr/bin/env python
#
# Written by katagiri on 2013/05/24
# This module provides the camfwlib API functions.
#

import sys
import os
sys.path.append(os.path.abspath('../..'))
import time
import camfwlib

cf = camfwlib.camfwClient('172.16.80.30', 15680, './camfw.log', camfwlib.DEBUG) 

cam_list = cf.get_cameralist()
cf.log(camfwlib.DEBUG, 'returned camera id list : ' + ' '.join(cam_list))

path = './images/'

while True:
    for cam in cam_list:
        filepath = path + cam + '.jpg'
        res = cf.get_snapshot(cam, filepath)
        if res == True:
            cf.log(camfwlib.DEBUG, filepath + ' updated')
    time.sleep(2.5)
